package org.alex.mqtt.common.bus;

import org.alex.mqtt.common.bus.model.DeviceSubscription;

import java.util.Set;

/**
 * 订阅管理器
 * @author : alex
 */
public interface DeviceSubscriptionManager {
    /**
     * 向子树添加订阅并持久化
     */
    boolean subscribe(DeviceSubscription deviceSubscription);

    /**
     * 从子树中移除订阅并删除持久化
     */
    boolean unSubscribe(String clientId, String topic);

    boolean isMatch(String pubTopic, String subTopic);

    boolean onlySubscribe2Tree(DeviceSubscription deviceSubscription);

    boolean onlyUnUnsubscribeFromTree(String clientId, String topic);

    /**
     * 获取所有订阅
     */
    Set<DeviceSubscription> getAllSubscription(String clientId);

    /**
     * 删除所有订阅
     */
    void deleteAllSubscription(String clientId);
}
